﻿using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using MyCompany.WebCrawler.Domain;

namespace MyCompany.WebCrawler.Test.Domain.DownloaderTests.Given_GoogleWebSite
{
    [TestClass]
    public class When_DownloadAndExtractLinks:Context
    {
        Mock<Downloader> mock;

        public override void Arrange()
        {
            var page = "<html><a href=\"http://google.com/ads\">Ads</a></html>";
            mock = new Mock<Downloader>();

            mock.Setup(downloader => downloader.DownloadString(It.IsAny<string>())).Returns(page);
        }

        public override void Act()
        {
            mock.Object.GetLinksFrom("http://google.com");
        }

        [TestMethod]
        public void Then_RealLinkIsGotten()
        {
            mock.Object.Links[0].Should().Be("http://google.com/ads");
        }

    }
}
